"""
规定当一定名称的文件名进入时，返回对应的pes值
"""


def get_pes_data(filename):
    flag_s = '-S' in filename and '-SJ' not in filename
    flag_sj = '-SJ' in filename
    flag_lx = '-LX' in filename
    flag_kh = '-KH' in filename
    flag_zk = '-ZK' in filename
    flag_jc = '-JC' in filename
    # 首件湿胶
    # 仅有‘-S’，不包含‘-SJ’，‘-LX’，‘-KH’以及‘-ZK’
    if flag_s and not flag_sj and not flag_kh and not flag_zk and not flag_jc:
        return '1'
    # 首件成品有离心的情况
    # '-S-LX-KH' || '-S-LX-ZK'
    # 首件成品没有离心的情况
    # '-S-KH' || '-S-ZK'
    # 首件成品可以不判断是否离心
    elif (flag_s and not flag_sj and flag_kh and not flag_zk and not flag_jc) \
            or (flag_s and not flag_sj and not flag_kh and flag_zk and not flag_jc):
        return '2'
    # 量产湿胶：有 ‘-SJ’，不判断 ‘-LX’,其余全为否定
    elif flag_sj and not flag_s and not flag_kh and not flag_zk and not flag_jc:
        return '3'
    # 量产转烤：有 ‘-ZK’，不判断 ‘-LX’,其余全为否定
    elif flag_zk and not flag_s and not flag_kh and not flag_sj and not flag_jc:
        return '4'
    # 量产成品：有 ‘-KH’，不判断 ‘-LX’,其余全为否定
    elif flag_kh and not flag_s and not flag_jc and not flag_zk and not flag_sj:
        return '5'
    # 机差对测：仅有 ‘-JC’,其余全为否定
    elif flag_jc and not flag_sj and not flag_s and not flag_zk and not flag_kh and not flag_lx:
        return '6'
    # 规定之外的名称
    else:
        return '0'


if __name__ == '__main__':
    list1 = ['1010-280-SJ', '1010-280-S', '1010-280-SJ-LX', '1010-280-LX-ZK', '1010-280-JC', '1010-280-S-ZK',
             '1010-280-LX-KH', '1010-280-ZK', '1010-280-KH']
    for name in list1:
        pes_data = get_pes_data(name)
        print(f"文件名：{name},标志：{pes_data}")
